import { Modal } from "antd";
import type { EamEquipmentMaintainProgram } from "@/pages/eam/maintainProgram/entity";
import DynamicQueryTable, { SelectionType } from "@/components/report/DynamicQueryTable";
import { useState } from "react";

interface MultiCheckMaintainProgramSelectorProps {
	open: boolean;
	onCancel: () => void;
	onOk: (selectedPrograms: EamEquipmentMaintainProgram[]) => void;
}

const MultiCheckMaintainProgramSelector:React.FC<MultiCheckMaintainProgramSelectorProps> = ({ open, onCancel, onOk }) => {
  
  // 选中的点检保养项目
  const [selectedPrograms, setSelectedPrograms] = useState<EamEquipmentMaintainProgram[]>([]);

  const handleOk = () => {
		onOk(selectedPrograms);
	};

	return (
		<Modal title="选择点检保养项目" open={open} onCancel={onCancel} onOk={handleOk} width={800} destroyOnClose>
			<DynamicQueryTable 
        reportCode="equipment_check_maintain_program_report" 
        selectionType={SelectionType.CHECKBOX}
        onSelectChange={(selectedRows) => {setSelectedPrograms(selectedRows)}}  
      />
		</Modal>
	);
}

export default MultiCheckMaintainProgramSelector;